Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate Workflow: Scope vindex names correctly when target and source keyspace have different names #16769

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rohit-nayak-ps
Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps commented Sep 12, 2024

Description

We use the target keyspace’s vindex for filtering out rows from the source intended for each target shard. The vindex is qualified by the target keyspace name. When the source cluster has a different name for the keyspace, it fails while trying to stream from the source cluster, because it cannot locate the vindex.

This PR sets the vindex scope to that of the source keyspace if the keyspace names differ. Note that it is assumed that the same vindexes are used on both keyspaces during a Migrate

Related Issue(s)

#16777

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Deployment Notes

…names are different, we need to scope the vindex used in the vreplication filter to the local name

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Copy link
Contributor

vitess-bot bot commented Sep 12, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Sep 12, 2024
@github-actions github-actions bot added this to the v21.0.0 milestone Sep 12, 2024
Copy link

codecov bot commented Sep 12, 2024

Codecov Report

Attention: Patch coverage is 54.54545% with 10 lines in your changes missing coverage. Please review.

Project coverage is 69.53%. Comparing base (1db282a) to head (e6a3989).
Report is 86 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtctl/workflow/materializer.go 50.00% 4 Missing ⚠️
go/vt/wrangler/materializer.go 50.00% 4 Missing ⚠️
go/vt/vtctl/workflow/server.go 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16769      +/-   ##
==========================================
+ Coverage   68.98%   69.53%   +0.54%     
==========================================
  Files        1562     1568       +6     
  Lines      200697   202442    +1745     
==========================================
+ Hits       138459   140764    +2305     
+ Misses      62238    61678     -560     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rohit-nayak-ps rohit-nayak-ps added Backport to: release-18.0 Needs to be back ported to release-18.0 Backport to: release-19.0 Needs to be back ported to release-19.0 Backport to: release-20.0 Needs to be backport to release-20.0 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Sep 13, 2024
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general it LGTM. I had some minor nits and suggestions, the only thing that I think we really should do is address the it is expected that the source and target keyspaces have the same vindex name and data type part and confirm that ourselves. Unless there's some reason(s) that we cannot?

go/test/endtoend/vreplication/migrate_test.go Outdated Show resolved Hide resolved
go/test/endtoend/vreplication/migrate_test.go Show resolved Hide resolved
go/vt/wrangler/materializer.go Outdated Show resolved Hide resolved
go/test/endtoend/vreplication/migrate_test.go Outdated Show resolved Hide resolved
if mz.workflowType == binlogdatapb.VReplicationWorkflowType_Migrate {
// For a Migrate, if the TargetKeyspace name is different from the SourceKeyspace name, we need to use the
// SourceKeyspace name to determine the vindex since the TargetKeyspace name is not known to the source.
// Note: it is expected that the source and target keyspaces have the same vindex name and data type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should check and confirm this expectation and error out if it's not true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is assumed that the vschemas and tables etc are identical on source and target for Migrate. We can/should add all vaidations for this and all other workflow types in another PR. I don't want to add that to this PR.

// cluster with keyspace rating.
func TestMigrateSharded(t *testing.T) {
setSidecarDBName("_vt")
defaultRdonly = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why set this? I don't see where we use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is that global variable that we have not refactored yet. It is used in creating future clusters in the test. Added code to keep previous values and reset in a defer.

go/test/endtoend/vreplication/migrate_test.go Outdated Show resolved Hide resolved
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport to: release-18.0 Needs to be back ported to release-18.0 Backport to: release-19.0 Needs to be back ported to release-19.0 Backport to: release-20.0 Needs to be backport to release-20.0 Component: VReplication Type: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants